package com.erci.mapper;

import com.erci.entity.Anime;
import com.erci.entity.DTO.AnimeDTO;
import com.erci.entity.Episode;
import com.erci.entity.VO.AnimeDetailVO;
import com.erci.entity.VO.AnimeUserVO;
import com.erci.entity.VO.AnimeVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AnimeMapper {

    List<Integer> queryIdsByCondition(String name, List<Integer> categoryIds, String status);

    Page<AnimeVO> queryListByIds(List<Integer> animeIds);

//    @Insert("insert into anime(name,image_url,status,create_time,update_time) values(#{name},#{imageUrl},#{status},#{createTime},#{updateTime})")
    void add(Anime anime);


    void addAnimeCategory(Integer animeId, List<Integer> categoryIds);

    @Delete("delete from anime where id=#{id}")
    void deleteById(Integer id);
    @Delete("delete from category_anime where anime_id= #{id}")
    void deleteAnimeCategory(Integer id);

    @Insert("update anime set name= #{name},image_url= #{imageUrl},status= #{status},update_time= #{updateTime},year=#{year},rating=#{rating},description=#{description}  where id= #{id}")
    void update(Anime anime);


    List<Integer> queryListUser(String name, Integer categoryId, String year);

    Page<AnimeUserVO> queryListUserByIds(List<Integer> animeIds);


    AnimeDetailVO queryDetail(Integer id);


}
